package com.zhousb.deviceManager.model.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author ZhouShenBin
 * @date 2024/7/4 19:59
 * @description
 */
@Getter
@AllArgsConstructor
public enum OrderStatusEnum {

    DEFAULT(-1,"未知"),
    SAVED(0,"已保存"),
    CREATED(1,"已下单"),
    LOCKED(2,"已锁单"),
    DELIVER(3,"已发货"),
    DELIVERED(4,"已签收"),
    CANCEL(9,"已撤销");

    private final Integer code;
    private final String name;

    public static OrderStatusEnum getInstance(Integer code){
        for (OrderStatusEnum orderStatusEnum : OrderStatusEnum.values()) {
            if (orderStatusEnum.getCode().equals(code)){
                return orderStatusEnum;
            }
        }
        return DEFAULT;
    }
}
